//
//  RBMeViewController.m
//  Budejie
//
//  Created by 华杨科技 on 2017/9/19.
//  Copyright © 2017年 饶波. All rights reserved.
//  我

#import "RBMeViewController.h"
#import "RBSettingViewController.h"
#import "RBMeCell.h"
#import "RBMeFootView.h"
@interface RBMeViewController () 

@end

@implementation RBMeViewController

- (instancetype)init {
    return [self initWithStyle:UITableViewStyleGrouped];
}

- (void)viewDidLoad {
    [super viewDidLoad];
       
    
    [self setTableView];

    [self setNav];
}

- (void)setTableView 
{
    self.view.backgroundColor = RBCommonbgcolor;
    
    self.tableView.sectionHeaderHeight = 0;
    self.tableView.sectionFooterHeight = RBMargin;
    self.tableView.contentInset = UIEdgeInsetsMake(RBMargin-35, 0, 0, 0);
    
    // 设置footer 
    self.tableView.tableFooterView = [[RBMeFootView alloc] init];
  
//    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
//        UIView *testFootView = [[UIView alloc] init];
//        testFootView.backgroundColor = [UIColor redColor];
//        testFootView.rb_height = 800;
//        self.tableView.tableFooterView = testFootView;
////        [self.tableView reloadData]; 
//        NSLog(@"%@",NSStringFromCGSize(self.tableView.contentSize));
//
//    });
}

//{320, 943}
//{320, 963}
- (void)setNav 
{
    // 标题
    self.navigationItem.title = @"我的";
    
    // 设置item
    UIBarButtonItem *settingItem = [UIBarButtonItem itemWithImage:@"mine-setting-icon" highlightImage:@"mine-setting-icon-click" target:self action:@selector(settingClick)];
    
    // 月亮item
    UIBarButtonItem *moonItem = [UIBarButtonItem itemWithImage:@"mine-moon-icon" highlightImage:@"mine-moon-icon-click" target:self action:@selector(moonClick)];
    
    self.navigationItem.rightBarButtonItems = @[settingItem,moonItem];
  
}

- (void)settingClick {
    
    RBSettingViewController *settingVC = [[RBSettingViewController alloc] init];
    [self.navigationController pushViewController:settingVC animated:YES];
    
}

- (void)moonClick {
    RBNSLogFunction
}

#pragma mark - UITableViewDataSource
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 2;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 1;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    static NSString *ID = @"meCellid";
    RBMeCell *cell = [self.tableView dequeueReusableCellWithIdentifier:ID];
    if (cell == nil) {
        cell = [[RBMeCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:ID];
    }

    cell.selectionStyle = UITableViewCellSelectionStyleNone;

    if (indexPath.section == 0) {
        cell.textLabel.text = @"登录/注册";
        cell.imageView.image = [UIImage imageNamed:@"publish-audio"]; // setup-head-default   publish-audio
//        cell.imageView.rb_x = 10; // 没用
    }else if (indexPath.section == 1){
        cell.textLabel.text = @"离线下载";
//        cell.imageView.image = nil; // 只要有其他cell设置了imgeView.image;其他不显示图片的cell都需要设置imageView.image = nil;
    }else{
        cell.textLabel.text  = @"其他";
//        cell.imageView.image = nil;
    }
    
    return cell;
}

@end
